const util = require('../../utils/until')

const api = require('../../config/api')

Page({

    data: {
        newGoods:[],
        coupon:[],
        channel:[],
        groupons:[],
        banner:[],
        brand:[],
        hotGoods:[],
        topic:[],
        floorGoods:[],
        goodsCount:0
    },
    getIndexData:function(){
        let that = this;
        util.request(api.IndexUrl).then(function(res){
            if(res.errno === 0){
                that.setData({
                    newGoods:res.data.newGoodsList,
                    coupon:res.data.couponList,
                    channel:res.data.channel,
                    groupons:res.data.grouponList,
                    banner:res.data.banner,
                    brand:res.data.brandList,
                    hotGoods:res.data.hotGoodsList,
                    topic:res.data.topicList,
                    floorGoods:res.data.floorGoodsList,
                })
            }
        });
        util.request(api.GoodsCount).then(function(res){
            that.setData({
                goodsCount:res.data.goodsCount
            })
        })

    },
    onLoad:function(options){
        this.getIndexData()
    }
    
})